package kun;

import java.awt.image.BufferedImage;
import java.util.Random;

public class Ep extends FlyObject {

    int sp;

    int hp;

    int type;

    Random rd = new Random();

    public Ep() {

        int index = rd.nextInt(5) + 1;

        String path = "/kun/img/ep" + (index < 10 ? "" : "") + index + ".png";

        type = index;

        img = App.getImg(path);


        w = img.getWidth();
        h = img.getHeight();
        x = rd.nextInt(510 - w);
        y = -h;
        sp = 3 - index + 10;
        hp = index * 4;
    }

    public void move() {
        if (type == 1) {
            x -= 2;
            y += sp;
        }else if(type == 2){
            x += 2;
            y += sp;
        }else {
            y += sp;
        }
    }

    public boolean fireBy(Fire f) {
        boolean hit = x <= f.x + f.w && x >= f.x - w &&
                y <= f.y + f.h && y >= f.y - h;
        return hit;
    }

    public boolean hitBy(Hero f) {
        boolean hit = x <= f.x + f.w && x >= f.x - w &&
                y <= f.y + f.h && y >= f.y - h;
        return hit;
    }
}
